{include file="include/top"}
<style>
    td,.layui-table th{
        text-align: center;!important;
    }
    .layui-col-md12{
        display: flex;
    }
</style>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">广告管理</a>
            <a>
              <cite>回收站</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" style="width: 100%;">
                <div class="layui-card-body ">
                    <div class="layui-row">
                        <form class="layui-form layui-col-md12 x-so" action="{:url('Adver/adverBin')}" method="get">
                            <input class="layui-input" placeholder="开始日" name="start" id="start" style="width: 15%;margin: 10px 10px 10px 0px">
                            <input class="layui-input" placeholder="截止日" name="end" id="end" style="width: 15%;margin: 10px 10px 10px 0px">
                            <div style="margin: 10px 10px 10px 0px;width: 120px;">
                                <select name="city" lay-verify="required">
                                    <option value="ae_name">广告标题</option>
                                </select>
                            </div>
                            <input type="text" name="key"  placeholder="请输入搜索内容" autocomplete="off" class="layui-input" style="width: 15%;margin: 10px 10px 10px 0px"   >
                            <input class="layui-btn" name="sub" type="submit" value="搜索" style="margin: 10px 10px 10px 0px">
                        </form>
                    </div>
                    <table class="layui-table layui-form" >
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>广告标题</th>
                            <th>广告图片</th>
                            <th>广告链接</th>
                            <th>发布时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="x-img">
                        {volist name="list" id="data"}
                        <tr>
                            <td>{$key+1}</td>
                            <td>{$data.ae_name}</td>
                            <td><img src="{$data.ae_img}"></td>
                            <td>{$data.ae_href}</td>
                            <td>{$data.ae_time|date="Y-m-d H:i:s",###}</td>
                            <td>
                                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="member_stop(this,'adver','ae_id','{$data.ae_id}','ae_state',1,'恢复')">
                                    <i class="layui-icon">&#xe669;</i>
                                </button>
                                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="del(this,'{$data.ae_id}')">
                                    <i class="layui-icon">&#xe640;</i>
                                </button>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
    //永久删除
    function del(obj,id) {
        layer.confirm('确认要永久删除此广告吗？（一但删除不可恢复！！！）',function(index){
            $.ajax({
                type:'post',
                url:'{:url("Adver/bin_del")}',
                dataType: 'json',
                data:{id:id},
                success: function(data){
                    if(data.code > 0){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else{
                        layer.msg(data.msg,{icon:5,time:2000})
                    }
                }
            });
        });
    }
    function member_stop(obj,table,id,where,field,state,title){
        $.ajax({
            type: 'POST',
            url: '{:url("index/updateStatus")}',
            dataType: 'json',
            data : {table:table,id:id,where:where,field:field,state:state},
            success: function(data){
                if(data.code>0){
                    layer.msg('已'+title,{icon:1,time:1000});
                    setTimeout(function () {
                        location.reload();
                    }, 1000);
                }else{
                    layer.msg(title+'失败',{icon:5,time:1000});
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });
    }
</script>
</html>